FROM alpine:latest

ENV TZ Asia/Shanghai

RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories \
  && apk add -U --no-cache tzdata aria2 nginx supervisor openssl \
  && wget https://github.com/ziahamza/webui-aria2/archive/master.tar.gz \
  && tar xvf master.tar.gz \
  && mv webui-aria2-master/docs /opt/aria2-webui \
  && mkdir -p /run/nginx/ \
  && mkdir -p /opt/conf/ \
  && ln -sf /dev/stdout /var/log/nginx/access.log \ 
  && ln -sf /dev/stderr /var/log/nginx/error.log \
  && rm -rf webui-aria2-master master.tar.gz

COPY entrypoint.sh /
COPY supervisor.conf /
COPY aria2.conf /opt/conf/
COPY conf.d/ /etc/nginx/conf.d/

RUN chmod +x entrypoint.sh

EXPOSE 8080

USER root

VOLUME ["/data"]

ENTRYPOINT ["/entrypoint.sh"]

CMD ["supervisord","-c","/supervisor.conf"]